package com.cw.jeeyt.service.converter.security;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.security.SecurityOrgBo;
import com.cw.jeeyt.service.bo.security.SecurityOrgVo;
import com.cw.jeeyt.dao.domain.security.SecurityOrgModel;
import com.cw.jeeyt.dao.model.security.SecurityOrgDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 组织机构转换类
 *
 * @author chenw
 * @date 2019-03-10 13:01:34
 */
public class SecurityOrgConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SecurityOrgBo do2Bo(SecurityOrgDo model) {
        if (model == null) {
            return null;
        }
        SecurityOrgBo bo = new SecurityOrgBo();
        bo.setOrgId(model.getOrgId());
        bo.setOrgCode(model.getOrgCode());
        bo.setOrgName(model.getOrgName());
        bo.setOrgType(model.getOrgType());
        bo.setOrgParentId(model.getOrgParentId());
        bo.setOrgParentCode(model.getOrgParentCode());
        bo.setOrgParentName(model.getOrgParentName());
        bo.setOrgComment(model.getOrgComment());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        bo.setOrgLevelCode(model.getOrgLevelCode());
        bo.setOrgState(model.getOrgState());
        // bo.setOrgAddress(model.getOrgAddress());
        // bo.setOrgPostCode(model.getOrgPostCode());
        // bo.setOrgEmail(model.getOrgEmail());
        // bo.setOrgPhone(model.getOrgPhone());
        // bo.setOrgFax(model.getOrgFax());
        // bo.setOrgSort(model.getOrgSort());
        // bo.setManagers(model.getManagers());
        // bo.setManagerIds(model.getManagerIds());
        // bo.setLeaders(model.getLeaders());
        // bo.setLeaderIds(model.getLeaderIds());
        // bo.setTopOrgs(model.getTopOrgs());
        // bo.setTopOrgIds(model.getTopOrgIds());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SecurityOrgDo bo2Do(SecurityOrgBo bo) {
        if (bo == null) {
            return null;
        }
        SecurityOrgDo model = new SecurityOrgDo();
        model.setOrgId(bo.getOrgId());
        model.setOrgCode(bo.getOrgCode());
        model.setOrgName(bo.getOrgName());
        model.setOrgType(bo.getOrgType());
        model.setOrgParentId(bo.getOrgParentId());
        model.setOrgComment(bo.getOrgComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        model.setOrgLevelCode(bo.getOrgLevelCode());
        model.setOrgState(bo.getOrgState());
        // model.setOrgAddress(bo.getOrgAddress());
        // model.setOrgPostCode(bo.getOrgPostCode());
        // model.setOrgEmail(bo.getOrgEmail());
        // model.setOrgPhone(bo.getOrgPhone());
        // model.setOrgFax(bo.getOrgFax());
        // model.setOrgSort(bo.getOrgSort());
        // model.setManagers(bo.getManagers());
        // model.setManagerIds(bo.getManagerIds());
        // model.setLeaders(bo.getLeaders());
        // model.setLeaderIds(bo.getLeaderIds());
        // model.setTopOrgs(bo.getTopOrgs());
        // model.setTopOrgIds(bo.getTopOrgIds());
        return model;
    }

    /**
     * vo转model
     *
     * @param vo
     * @return
     */
    public static SecurityOrgModel vo2Model(SecurityOrgVo vo) {
        if (vo == null) {
            return null;
        }
        SecurityOrgModel model = new SecurityOrgModel();
        model.setOrgId(vo.getOrgId());
        model.setOrgCode(vo.getOrgCode());
        model.setOrgName(vo.getOrgName());
        model.setOrgType(vo.getOrgType());
        model.setOrgParentId(vo.getOrgParentId());
        model.setOrgComment(vo.getOrgComment());
        model.setCreateBy(vo.getCreateBy());
        model.setCreateDate(vo.getCreateDate());
        model.setUpdateBy(vo.getUpdateBy());
        model.setUpdateDate(vo.getUpdateDate());
        model.setOrgLevelCode(vo.getOrgLevelCode());
        model.setOrgState(vo.getOrgState());
        // bo.setOrgAddress(model.getOrgAddress());
        // bo.setOrgPostCode(model.getOrgPostCode());
        // bo.setOrgEmail(model.getOrgEmail());
        // bo.setOrgPhone(model.getOrgPhone());
        // bo.setOrgFax(model.getOrgFax());
        // bo.setOrgSort(model.getOrgSort());
        // bo.setManagers(model.getManagers());
        // bo.setManagerIds(model.getManagerIds());
        // bo.setLeaders(model.getLeaders());
        // bo.setLeaderIds(model.getLeaderIds());
        // bo.setTopOrgs(model.getTopOrgs());
        // bo.setTopOrgIds(model.getTopOrgIds());
        return model;
    }

    /**
     * bo转do
     *
     * @param model
     * @return
     */
    public static SecurityOrgVo model2Vo(SecurityOrgModel model) {
        if (model == null) {
            return null;
        }
        SecurityOrgVo vo = new SecurityOrgVo();
        vo.setOrgId(model.getOrgId());
        vo.setOrgCode(model.getOrgCode());
        vo.setOrgName(model.getOrgName());
        vo.setOrgType(model.getOrgType());
        vo.setOrgParentId(model.getOrgParentId());
        vo.setOrgComment(model.getOrgComment());
        vo.setCreateBy(model.getCreateBy());
        vo.setCreateDate(model.getCreateDate());
        vo.setUpdateBy(model.getUpdateBy());
        vo.setUpdateDate(model.getUpdateDate());
        vo.setOrgLevelCode(model.getOrgLevelCode());
        vo.setOrgState(model.getOrgState());
        // model.setOrgAddress(bo.getOrgAddress());
        // model.setOrgPostCode(bo.getOrgPostCode());
        // model.setOrgEmail(bo.getOrgEmail());
        // model.setOrgPhone(bo.getOrgPhone());
        // model.setOrgFax(bo.getOrgFax());
        // model.setOrgSort(bo.getOrgSort());
        // model.setManagers(bo.getManagers());
        // model.setManagerIds(bo.getManagerIds());
        // model.setLeaders(bo.getLeaders());
        // model.setLeaderIds(bo.getLeaderIds());
        // model.setTopOrgs(bo.getTopOrgs());
        // model.setTopOrgIds(bo.getTopOrgIds());
        return vo;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static ArrayList<SecurityOrgBo> doList2BoList(List<SecurityOrgDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SecurityOrgConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SecurityOrgDo> boList2DoList(List<SecurityOrgBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SecurityOrgConverter::bo2Do));
    }

    public static ArrayList<SecurityOrgVo> modelList2VoList(List<SecurityOrgModel> orgList) {
        if (CollectionUtil.isEmpty(orgList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(orgList.iterator(), SecurityOrgConverter::model2Vo));
    }
}
